package com.oracle.zebrafreelytraveling.net;

import com.oracle.zebrafreelytraveling.data.RequestResult.ResBase;
import com.oracle.zebrafreelytraveling.data.RequestResult.ResCard;
import com.oracle.zebrafreelytraveling.data.RequestResult.ResCircle;
import com.oracle.zebrafreelytraveling.data.RequestResult.ResFoodInfo;
import com.oracle.zebrafreelytraveling.data.RequestResult.ResHotelList;
import com.oracle.zebrafreelytraveling.data.RequestResult.ResReCards;
import com.oracle.zebrafreelytraveling.data.RequestResult.ResState;
import com.oracle.zebrafreelytraveling.data.RequestResult.ResUser;
import com.oracle.zebrafreelytraveling.data.RequestResult.ResViewSpotIntro;
import com.oracle.zebrafreelytraveling.data.RequestResult.ResViewSpotList;
import com.oracle.zebrafreelytraveling.data.bean.Card;
import com.oracle.zebrafreelytraveling.data.bean.Replay;
import com.oracle.zebrafreelytraveling.data.bean.User;
import com.oracle.zebrafreelytraveling.utils.constant.Constant;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;

/**
 * Created by yydcnjjw on 2017/7/20.
 */

public interface Api {

    @FormUrlEncoded
    @POST("updateUserInfo/")
    Observable<ResState> updateUserInfo(@Field("updateUserInfo") String userInfo);

    @FormUrlEncoded
    @POST("login/")
    Observable<ResUser> getResLogin(@Field("account") String account,
                                    @Field("password") String password);

    /**
     * 注册
     *
     * @param account
     * @param password
     * @param tel
     * @param email
     * @return 返回是否成功
     */
    @FormUrlEncoded
    @POST("logup/")
    Observable<ResState> getResLogUP(@Field("account") String account,
                                     @Field("password") String password,
                                     @Field("nickname") String name,
                                     @Field("tel") String tel,
                                     @Field("email") String email);
    /**
     * 获取帖子接口
     *
     * @param site    城市
     * @param page    页码
     * @param maxPage 最大页数
     * @return 返回
     */
    @FormUrlEncoded
    @POST("CardsWithCity/")
    Observable<ResCard> getResCardsFromCity(@Field("site") String site,
                                            @Field("page") int page,
                                            @Field("maxPage") int maxPage);

    @FormUrlEncoded
    @POST("CardsWithCountry/")
    Observable<ResCard> getResCardsFromCountry(@Field("page") int page,
                                               @Field("maxPage") int maxPage);


    @Multipart
    @POST("uploadToUser/")
    Observable<ResState> uploadFile(@Part MultipartBody.Part file);


    @FormUrlEncoded
    @POST("getReCardFromCard/")
    Observable<ResReCards> getReCardFromCard(@Field("cardId") int cardId,
                                             @Field("page") int page,
                                             @Field("maxPage") int maxPage);

    /**
     * 添加帖子
     */
    @FormUrlEncoded
    @POST("addCard/")
    Observable<ResState> addCards(@Field("card") String card);

    /**
     * 按照标签获取帖子
     * @param city
     * @param label
     * @param page
     * @param maxPage
     * @return
     */
    @FormUrlEncoded
    @POST("CardsWithLabel/")
    Observable<ResCard> getCardsWithLabel(@Field("site") String city,
                                          @Field("label") int label,
                                          @Field("page") int page,
                                          @Field("maxPage") int maxPage);

    @FormUrlEncoded
    @POST("getCardsByUserId/")
    Observable<ResBase<List<Card>>> getCardsByUserId(@Field("userId") int userId,
                                               @Field("page") int page,
                                               @Field("maxPage") int maxPage);

    /**
     * 添加一个回帖
     * @return
     */
    @FormUrlEncoded
    @POST("reCard/")
    Observable<ResBase<Replay>> addReCards(@Field("reply") String reply);

    @FormUrlEncoded
    @POST("circleListFromCity/")
    Observable<ResCircle> getCircleListFromCity(@Field("city") String city,
                                                @Field("page") int page,
                                                @Field("maxPage") int maxPage);

    @FormUrlEncoded
    @POST("circleListFromCountry/")
    Observable<ResCircle> getCircleListFromCountry(@Field("page") int page,
                                                   @Field("maxPage") int maxPage);

    @FormUrlEncoded
    @POST("getCircleByUserId/")
    Observable<ResCircle> getCircleByUserId(@Field("userId") int userId,
                                            @Field("page") int page,
                                            @Field("maxPage") int maxPage);

    @FormUrlEncoded
    @POST("joinCircle/")
    Observable<ResState> joinCircle(@Field("userId") int userId,
                                    @Field("circleId") int circleId);

    @GET("catering/query?key=" + Constant.FOOD_KEY)
    Observable<ResFoodInfo> getFoodInfo(@Query("lat") double latitude,
                                        @Query("lng") double longitude,
                                        @Query("page") int page);


    @GET("catering/query?key=" + Constant.FOOD_KEY)
    Observable<ResFoodInfo> getFoodInfoByCity(@Query("city") String city,
                                              @Query("page") int page,
                                              @Query("pagesize") int pagesize);

    @GET("scenery?key=" + Constant.VIEW_KEY)
    Observable<ResViewSpotList> getViewSpotList(@Query("cid") int cityId,
                                                @Query("page") int page);

    @GET("GetScenery?sid=31365&key=" + Constant.VIEW_KEY)
    Observable<ResViewSpotIntro> getViewSpotIntro(@Query("sid") int sceneryId);

    @GET("HotelList?key=" + Constant.VIEW_KEY)
    Observable<ResHotelList> getHotelList(@Query("cityId") int cityId,
                                          @Query("page") int page);

    /**
     * 通过城市名字检索获取城市id
     * @param city
     * @return
     */
    @FormUrlEncoded
    @POST("getCityId/")
    Observable<ResBase<Integer>> getCityId(@Field("city") String city);

    @FormUrlEncoded
    @POST("getUserList/")
    Observable<ResBase<List<User>>> getUserList(@Field("type") int type,
                                            @Field("id") int id,
                                            @Field("page") int page,
                                            @Field("maxPage") int maxPage);

    @FormUrlEncoded
    @POST("getUser/")
    Observable<ResBase<User>> getUser(@Field("userId") int userId);

    @FormUrlEncoded
    @POST("concernUser/")
    Observable<ResState> concernUser(@Field("userId") int userId,
                                     @Field("cardUserId") int cardUserId);

    @FormUrlEncoded
    @POST("addFriend/")
    Observable<ResState> addFriend(@Field("userId") int userId,
                                     @Field("friendId") int friendId);


}
